﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.VCProjectEngine;
using EnvDTE;

using iMainAddin;

namespace iProjectAddin
{
    public class iProjectDoucment : ExchangeDocument
    {
        public bool StartChange(ProjectItem fileItem)
        {
            if (fileItem == null)
                return false;

            TextDocument document = fileItem.Document.Object("TextDocument") as TextDocument;

            if (document == null)
                return false;

            EditPoint ep = document.EndPoint.CreateEditPoint();
            EditPoint sp = document.StartPoint.CreateEditPoint();

            sp.CharLeft(1);
            string srcText = sp.GetText(ep);

            if (!ChangeTextVariables(ref srcText))
                return false;

            sp.Delete(ep);
            sp.Insert(srcText);

            return true;

        }
    }
}
